package com.party.course.eumn;

/**
 *
 */
public enum OrderState {
    ORDER_CREATED(0, "订单生成"),
    PAYING(1, "支付中"),
    PAYMENT_SUCCESS(2, "支付成功"),
    PAYMENT_FAILED(3, "支付失败"),
    ORDER_REVOKED(4, "已撤销"),
    ORDER_CLOSED(6, "订单关闭");

    private final int code;
    private final String description;

    OrderState(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static String getOrderStateByCode(int code) {
        for (OrderState state : OrderState.values()) {
            if (state.getCode() == code) {
                return state.getDescription();
            }
        }
        return "未知状态";
    }
}
